<?php

namespace App\Http\Controllers;

use App\Luodiye;
use App\Repository\ToutiaoRepository;
use App\WechatLink;
use Illuminate\Http\Request;

class LuodiyeController extends Controller
{
    protected $toutiaoRepository;
    public function __construct(ToutiaoRepository  $toutiaoRepository)
    {
        $this->toutiaoRepository=$toutiaoRepository;
    }

    public function luodiye(Request  $request,$id){
     $clickId=   $request->input('clickid','');
        $luodiyeUrl=   Luodiye::find($id);
        $url=WechatLink::find($luodiyeUrl->link_id)->url;
     if ($clickId){
            $url=$url.'?clickid='.$clickId;
         $this->toutiaoRepository->callback('consult_effective',$request->input('clickid'));
     }
      return view('luodiye',['id'=>$id,'url'=>$url]);
    }
}
